package com.tianfeng.fenghuotoutiao.ui.activity.video;

import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tianfeng.fenghuotoutiao.R;
import com.tianfeng.fenghuotoutiao.model.bean.UserBean;
import com.tianfeng.fenghuotoutiao.net.api.ApiSMSSend;
import com.tianfeng.fenghuotoutiao.net.api.user.userInfo.ApiBindPhoneNumber;
import com.tianfeng.fenghuotoutiao.net.api.user.userInfo.ApiOnlyBindPhoneNumber;
import com.tianfeng.fenghuotoutiao.net.bean.ResEmpty;
import com.tianfeng.fenghuotoutiao.ui.activity.UserNowTixianActivity;
import com.tianfeng.fenghuotoutiao.ui.activity.base.BaseActivity;
import com.tianfeng.fenghuotoutiao.utils.UIUtils;
import com.tianfeng.fenghuotoutiao.utils.ValidUtils;
import com.zhxu.library.http.HttpManager;
import com.zhxu.library.listener.HttpOnNextListener;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;

import butterknife.BindView;
import butterknife.OnClick;
import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.PlatformActionListener;
import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.wechat.moments.WechatMoments;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;


public class UserNowTixianStatus1Activity extends BaseActivity {
    private static final String TYPE_WECHAT = "type_wechat";
    private static final String TYPE_WECHAT_MOMENT = "type_wechat_moment";

    private IWXAPI api;
    @Override
    protected void initView(View rootView, Bundle savedInstanceState) {
        if (isLogin()){
            UserBean userBean=getUserBean();
            gomethod(userBean.getUserid());
        }

    }
    @BindView(R.id.btn_commshare)
    Button btn_commshare;
    @BindView(R.id.datime)
    TextView datime;

    @OnClick(R.id.tv_back)
    public void onClickBack() {
        finish();
    }




    @Override
    public int getContentLayout() {
        return R.layout.activity_usernowtixianstatusactivity;
    }


    /**
     * 提现东西提交
     */
    public void gomethod(String id){
        OkHttpClient okHttpClient=new OkHttpClient();
        final Request request = new Request.Builder()
                .url("http://tianze1688.com/api/index.php/news/user/selectrMethod?osversion=7.1.2&sign=4524d2ddd1e6365daf499c914c425423&versionCode=18&adCode=18&timesc=1557912690304&phonemodel=xiaomi&phonetype=2&deviceid=864699035010366&channel=8&from_uid="+id+"&status="+"0")
                .get()//默认就是GET请求，可以不写
                .build();
        Call call = okHttpClient.newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String result = response.body().string();
                if (TextUtils.isEmpty(result)) return;
                JSONObject jsonObject= null;
                try {
                    jsonObject = new JSONObject(result);
                    String data=jsonObject.optString("data");
                    JSONObject jsonObject1=new JSONObject(data);
                    String status=jsonObject1.getString("status");
                    String addtime=jsonObject1.getString("addtime");

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            datime.setText(addtime);
                            switch (status){
                                case "0":
                                    btn_commshare.setText("审批中..");
                                    break;
                                case "1":
                                    btn_commshare.setText("通过..");
                                    break;
                                case "2":
                                    btn_commshare.setText("排号中..");
                                    break;
                                case "3":
                                    btn_commshare.setText("打款成功..");
                                    break;
                                case "4":
                                    btn_commshare.setText("拒绝..");
                                    break;


                            }
                        }
                    });


                } catch (JSONException e) {
                    e.printStackTrace();
                }


            }
        });
    }






}
